<template>
	<view class="module flex_ZC">
		<!-- #ifdef H5 -->
		<uNavbar title="开通账款服务"> </uNavbar>
		<!-- #endif -->
		<!-- #ifdef MP-WEIXIN -->
		<image class="indexbg" :src="baseUrl +'/static/image/indexbg.png'" mode="aspectFill"></image>
		<view class="custom_box">
			<view :style="{height: statusBarHeight + 'px', backgroundColor: backgroundColor }"></view>
			<view class="custom_nav " :style="{height: titleHeight + 'px', backgroundColor: backgroundColor}">
				<image class="goback" :src="baseUrl +'/static/icon/i_left.png'" mode="aspectFill" @click="leftClick">
				</image>
				<text class="f28 c3">开通账款服务</text>
			</view>
		</view>
		<view :style="{height: statusBarHeight + titleHeight + 'px'}" style="width: 100%;"></view>
		<!-- #endif -->

		<view class="sylc_box flex_Z">
			<text class="sylc">使用流程</text>
			<view class="technological mt20 flex_ld_a">
				<view class="first flex_ZC">
					<image :src="baseUrl +  '/static/icon/i_jbxx.png'" mode="aspectFill"></image>
					<text class="f30 c2 fw7">基本信息</text>
				</view>
				<view class="xuxian flex_dq">
					<image :src="baseUrl +  '/static/icon/i_ls1.png'" mode="aspectFill"></image>
				</view>
				<view class="second flex_ZC">
					<image :src="baseUrl +  '/static/icon/i_bdyhk.png'" mode="aspectFill"></image>
					<text class="f28 c9 fw7">绑定银行卡</text>
				</view>
				<!-- 				<view class="xuxian2 flex_dq">
					<image :src="baseUrl + '/static/icon/speed1.png'" mode="aspectFill"></image>
				</view>
				<view class="second flex_ZC">
					<image :src="baseUrl +  '/static/icon/i_sqqy.png'" mode="aspectFill"></image>
					<text class="f30 c9  fw7">授权签约</text>
				</view> -->
			</view>
		</view>

		<view class="store_name flex_dq">
			<text>{{storeName}}</text>
		</view>

		<view class="supplement mt24">
			<text class="f32 c3 fw7">商户补充信息</text>
			<view class="mt40 flex_Z lineb">
				<view class=" flex_dq">
					<text class="f28 c3">商户简称</text>
					<text class="c32 c1 ml8"> *</text>
				</view>
				<u--input placeholder="请输入商户简称(20字符以内)" fontSize="14" color="#666666" border="none " @change="aaaaa"
					v-model.trim="abbreviation" clearable></u--input>
			</view>
			<view class="mt24 flex_Z lineb">
				<view class=" flex_dq">
					<text class="f28 c3">小票名称</text>
					<text class="c32 c1 ml8"> * </text>
					<text class="f24 c9 ml8"> (显示在机打小票商户名一栏)</text>
				</view>
				<u--input placeholder="请输入小票名称(40字符以内)" fontSize="14" color="#666666" border="none "
					v-model.trim="receipt" clearable></u--input>
			</view>
		</view>


		<view class="supplement mt24">
			<text class="f32 c3 fw7">管理员信息</text>
			<view class="mt40 flex_Z lineb">
				<view class=" flex_dq">
					<text class="f28 c3">管理员账号</text>
					<text class="c32 c1 ml8 mr10"> *</text>
				</view>
				<view class="lanse ">
					<u-icon name="error-circle" color="#579BFF" size="12"></u-icon>
					<text class="f20 c2">默认为会员登录手机号</text>
				</view>
				<u--input placeholder="请输入管理员账号" fontSize="14" color="#666666" border="none " disabled
					v-model.trim="account" clearable></u--input>
			</view>
			<view class="mt24 flex_Z lineb">
				<view class=" flex_dq">
					<text class="f28 c3">管理员手机号</text>
					<text class="c32 c1 ml8"> *</text>
				</view>
				<u--input placeholder="请输入管理员手机号" fontSize="14" color="#666666" border="none " disabled
					v-model.trim="mobile" clearable></u--input>
			</view>
			<view class="mt24 flex_Z lineb">
				<view class=" flex_dq">
					<text class="f28 c3">管理员邮箱</text>
					<text class="c32 c1 ml8"> *</text>
				</view>
				<u--input placeholder="请输入管理员邮箱" fontSize="14" color="#666666" border="none " v-model.trim="email"
					clearable></u--input>
			</view>
		</view>
		<view class="supplement mt24">
			<view class=" flex_ld">
				<text class="f28 c3 fw7">是否需要经办人代替法人在线签约</text>
				<u-switch v-model="contactsShow" size="20" @change="changeJbr"></u-switch>
			</view>
			<view v-if="contactsShow">
				<view class="mt24 flex_Z lineb">
					<view class=" flex_dq">
						<text class="f28 c3">经办人姓名</text>
						<text class="c32 c1 ml8"> *</text>
					</view>
					<u--input placeholder="请输入经办人姓名" fontSize="14" color="#666666" border="none " v-model.trim="contacts_name" clearable></u--input>
				</view>
				<view class="mt24 flex_Z lineb">
					<view class=" flex_dq">
						<text class="f28 c3">经办人手机号</text>
						<text class="c32 c1 ml8"> *</text>
					</view>
					<u--input placeholder="请输入经办人手机号" fontSize="14" color="#666666" border="none " v-model.trim="contacts_mobile" clearable></u--input>
				</view>
				<view class="mt24 flex_Z lineb">
					<view class=" flex_dq">
						<text class="f28 c3">经办人身份证号</text>
						<text class="c32 c1 ml8"> *</text>
					</view>
					<u--input placeholder="请输入经办人身份证号" fontSize="14" color="#666666" border="none " v-model.trim="contacts_id_number"
						clearable></u--input>
				</view>
			</view>
		</view>

		<view class="btns mt24 flex_c">
			<text class="service" @click="nextTick">下一步</text>
		</view>


	</view>
</template>

<script>
	import {
		settledThreeSave,
		settledDetails
	} from "../../api/join.js"
	export default {
		data() {
			return {
				statusBarHeight: 0, //状态栏高度
				titleHeight: 0, // 标题栏高度
				backgroundColor: '',
				baseUrl: this.$imageBaseUrl,

				sellerId: '',
				examineState: 1, //是否入驻
				abbreviation: '',
				receipt: '',
				account: '',
				mobile: '',
				email: '',
				promptShow: false,
				contactsShow:false,
				storeName: '',
				contacts_name:'',
				contacts_id_number:'',
				contacts_mobile:'',
			}
		},
		onReady() {
			// #ifdef MP-WEIXIN 
			uni.getSystemInfo({
				success: res => {
					this.statusBarHeight = res.statusBarHeight
					console.log(this.statusBarHeight);
				}
			})
			const custombar = uni.getMenuButtonBoundingClientRect();
			this.titleHeight = (custombar.top - this.statusBarHeight) * 2 + custombar.height
			console.log(this.titleHeight);
			// #endif

		},

		onLoad() {},
		onShow() {
			this.account = uni.getStorageSync('mobile') || ''
			this.mobile = uni.getStorageSync('mobile') || ''
			this.applicationDetails()
		},
		methods: {
			changeJbr(e) {
				this.contactsShow = e
			},
			leftClick() {
				//获取页面栈的长度
				const canNavBack = getCurrentPages()
				console.log(canNavBack.length);
				// 判断是否刷新了浏览器，刷新了浏览器，页面栈只有当前一个
				if (canNavBack.length > 1) {
					uni.navigateBack({
						delta: 1
					})
				} else {
					uni.switchTab({
						url: '/pages/index/cloudCatIndex'
					})
				}
			},
			aaaaa(e) {
				console.log(e);
			},
			// 详情
			applicationDetails() {
				settledDetails().then(res => {
					console.log(res);
					if (res.code == 1) {
						this.storeName = res.data.name
						if (res.data.seller_auth) {
							this.sellerId = res.data.id
							this.email = res.data.email
							let sellerAuth = res.data.seller_auth;
							this.abbreviation = sellerAuth.license_short_name
							this.receipt = sellerAuth.receipt_name
							this.contactsShow = sellerAuth.contacts_legal?true:false
							this.contacts_name = sellerAuth.contacts_name
							this.contacts_id_number = sellerAuth.contacts_id_number
							this.contacts_mobile = sellerAuth.contacts_mobile
						}
					}
				})
			},


			nextTick() {
				if (uni.$u.test.isEmpty(this.abbreviation)) {
					uni.$u.toast('请输入商户简称');
					return;
				}
				if (uni.$u.test.isEmpty(this.receipt)) {
					uni.$u.toast('请输入小票名称');
					return;
				}
				if (!uni.$u.test.email(this.email)) {
					uni.$u.toast('请输入正确邮箱');
					return;
				}
				if(this.contactsShow){
					if (uni.$u.test.isEmpty(this.contacts_name)) {
						uni.$u.toast('请输入经办人姓名');
						return;
					}
					if (!uni.$u.test.mobile(this.contacts_mobile)) {
						uni.$u.toast('请输入经办人手机号');
						return;
					}
					if (!uni.$u.test.idCard(this.contacts_id_number)) {
						uni.$u.toast('请输入经办人身份证号');
						return;
					}
				}
				let data = {
					seller_id: this.sellerId,
					license_short_name: this.abbreviation,
					receipt_name: this.receipt,
					email: this.email,
					contacts_legal:this.contactsShow?1:0,
					contacts_name: this.contacts_name,
					contacts_mobile: this.contacts_mobile,
					contacts_id_number: this.contacts_id_number,
					mask: 1
				};
				console.log(data);
				settledThreeSave(data).then(res => {
					console.log(res);
					if (res.code == 1) {
						uni.navigateTo({
							url: '/pagesMy/businessJoin/openBankCard'
						})
					}
				})
			},
		},
		// 页面滚动
		onPageScroll: function(e) {
			const scrollTop = e.scrollTop; // 获取页面滚动位置
			// 根据滚动位置修改状态栏样式
			if (scrollTop > 20) {
				this.backgroundColor = '#ffffff';
			} else {
				this.backgroundColor = '';
			}
			// console.log("滚动距离为：" + e.scrollTop);
		},
	}
</script>

<style scoped>
	.module {
		width: 750rpx;
		margin: 0 auto;
	}

	.custom_box {
		width: 750rpx;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 9;
		padding-bottom: 10rpx;
		opacity: 1;
	}

	.indexbg {
		position: absolute;
		top: 0;
		left: 0;
		width: 750rpx;
		height: 260rpx;
		z-index: 7;
	}

	.custom_nav {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 750rpx;
		font-size: 36rpx;
		z-index: 9;
		color: #FFFFFF;
	}

	.goback {
		position: absolute;
		left: 30rpx;
		text-align: center;
		width: 40rpx;
		height: 40rpx;
	}

	.mt24 {
		margin-top: 24rpx;
	}

	.mt40 {
		margin-top: 40rpx;
	}

	.ml8 {
		margin-left: 8rpx;
	}

	.mr10 {
		margin-right: 10rpx;
	}


	.sylc_box {
		background: #ffffff;
		border-radius: 14rpx;
		box-shadow: 0rpx 0rpx 14rpx 0rpx rgba(0, 0, 0, 0.05);
		margin-bottom: 60rpx;
		/* #ifdef H5 */
		margin-top: 24rpx;
		/* #endif */
	}

	.technological {
		position: relative;
		width: 690rpx;
		padding: 30rpx 0;
	}

	.sylc {
		font-size: 32rpx;
		color: #333333;
		margin: 20rpx 30rpx 0;
	}

	.first {
		width: 200rpx;
	}

	.first>image {
		width: 70rpx;
		height: 70rpx;
		border-radius: 50%;
		margin-bottom: 30rpx;
	}

	.second {
		width: 200rpx;
	}

	.second>image {
		width: 70rpx;
		height: 70rpx;
		border-radius: 50%;
		margin-bottom: 30rpx;
	}

	.xuxian {
		position: absolute;
		top: 50rpx;
		left: 50%;
		transform: translateX(-50%);
		width: 100rpx;
	}

	.xuxian>image {
		width: 60rpx;
		height: 36rpx;
	}

	.xuxian2 {
		position: absolute;
		top: 50rpx;
		left: 70%;
		transform: translateX(-50%);
		width: 100rpx;
	}

	.xuxian2>image {
		width: 60rpx;
		height: 36rpx;
	}

	.store_name {
		width: 690rpx;
		font-size: 34rpx;
		color: #333333;
		font-weight: 700;
	}

	.supplement {
		width: 686rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 8rpx 40rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 14rpx 14rpx 14rpx 14rpx;
		padding: 24rpx 32rpx;
	}

	.lineb {
		border-bottom: 1rpx solid rgba(100, 100, 100, 0.1);
	}

	.lanse {
		display: flex;
		align-items: baseline;
		padding: 6rpx 16rpx;
		width: 616rpx;
		background: #EEF1FF;
		border-radius: 6rpx 6rpx 6rpx 6rpx;
		margin: 10rpx 0;
	}

	.lanse>text {
		margin-left: 6rpx;
	}

	.btns {
		width: 750rpx;
		height: 120rpx;
		background: #f8f8f8;
	}

	.service {
		width: 690rpx;
		height: 88rpx;
		line-height: 88rpx;
		font-size: 32rpx;
		color: #ffffff;
		font-weight: 500;
		text-align: center;
		background: #579BFF;
		border-radius: 20rpx;
	}



	.prompt {
		width: 650rpx;
		background: #ffffff;
		margin: 0 auto;
		border-radius: 20rpx;
		padding-top: 10rpx;
		padding-bottom: 40rpx;
	}

	.prompt>text {
		margin-top: 40rpx;
	}

	.prompt_tit {
		margin: 20rpx 48rpx;
		font-size: 28rpx;
		text-align: justify;
		color: #666666;
	}

	.prompt_ntm {
		width: 100%;
		font-size: 30rpx;
		margin-top: 50rpx;
	}

	.prompt_btn1 {
		width: 254rpx;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		background: #F2F2F2;
		border-radius: 40rpx;
		color: #333333;
	}

	.prompt_btn2 {
		width: 254rpx;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		background: #FFCC28;
		border-radius: 40rpx;
		color: #333333;
	}

	/deep/.u-input__content {
		margin-left: -20rpx;
	}
</style>